<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>JAP统一登录认证软件</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.14.0/css/all.min.css" />
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.15.8/styles/monokai-sublime.min.css"/>
</head>
<body>
<div class="container">
    <nav class="navbar navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="/">
            <img src="/img/justauth@0,75x.png" width="30" height="30" alt="" loading="lazy">
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="/">首页 <span class="sr-only">(current)</span></a>
                </li>
            </ul>
        </div>
    </nav>

    <div class="jumbotron mt-2 p-4">
        <h1 class="display-4">JAP统一登录认证软件</h1>
        <p class="lead">Just auth for any app</p>
        <!--<hr class="my-4">
        <a class="btn btn-info" href="https://gitee.com/yadong.zhang/JustAuth" target="_blank" role="button">Gitee <img src="https://gitee.com/yadong.zhang/JustAuth/badge/star.svg?theme=gvp" alt="star"></a>
        <a class="btn btn-info" href="https://github.com/zhangyd-c/JustAuth" target="_blank" role="button">Github <img src="https://img.shields.io/github/stars/zhangyd-c/JustAuth.svg?style=social" alt="github"></a>-->
        <a class="btn btn-info" href="/logout" role="button">退出</a>
        <a class="btn btn-info" href="/enableSso" role="button">切换 Session / SSO（Cookie）</a>
        <span th:if="${strategy} ne null" class="ml-2">
            当前登录使用的策略：<span class="badge badge-light" th:text="${strategy}"></span>
        </span>
        <span class="ml-2">
            <span class="badge badge-primary" th:if="${sso}" >启用 SSO</span>
            <span class="badge badge-light" th:if="${!sso}" >启用 Session</span>
        </span>
    </div>
    <div class="alert alert-danger mb-2" id="errorMsg" role="alert"></div>
    <div class="card">
        <div class="card-body">
            访问资源服务：<a href="/api/user">/api/user</a>，如果已登录，会正常跳转到 /api/user，如果未登录，会跳转回首页
        </div>
    </div>

    <div class="row mt-3">
        <div class="col col-4">
            <div class="accordion" id="accordionExample">
                <div class="card">
                    <div class="card-header p-2" id="simpleHeader">
                        <h2 class="mb-0">
                            <button class="btn btn-link btn-block text-left text-secondary" type="button" data-toggle="collapse" data-target="#simpleContainer" aria-expanded="true" aria-controls="simpleContainer">
                                <i class="fas fa-coffee mr-2"></i>simple
                            </button>
                        </h2>
                    </div>
                    <div id="simpleContainer" class="collapse show" aria-labelledby="simpleHeader" data-parent="#accordionExample">
                        <div class="card-body p-2">
                            <ul class="list-unstyled mb-0 pl-2">
                                <li>
                                    <a href="/simple/login">账号密码登录</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header p-2" id="socialHeader">
                        <h2 class="mb-0">
                            <button class="btn btn-link btn-block text-left text-secondary collapsed" type="button" data-toggle="collapse" data-target="#socialContainer" aria-expanded="false" aria-controls="socialContainer">
                                <i class="fas fa-coffee mr-2"></i>social
                            </button>
                        </h2>
                    </div>
                    <div id="socialContainer" class="collapse" aria-labelledby="socialHeader" data-parent="#accordionExample">
                        <div class="card-body p-2">
                            <ul class="list-unstyled mb-0 pl-2">
                                <li>
                                    <img src="https://cdn.jsdelivr.net/gh/justauth/justauth-oauth-logo@1.5/gitee.png" alt="" style="width: 20px;position: relative;top: -2px;;" class="mr-1">
                                    <a href="/social/login/gitee">Gitee 登录</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header p-2" id="oauth2Header">
                        <h2 class="mb-0">
                            <button class="btn btn-link btn-block text-left text-secondary collapsed" type="button" data-toggle="collapse" data-target="#oauth2Container" aria-expanded="false" aria-controls="oauth2Container">
                                <i class="fas fa-coffee mr-2"></i>oauth2
                            </button>
                        </h2>
                    </div>
                    <div id="oauth2Container" class="collapse" aria-labelledby="oauth2Header" data-parent="#accordionExample">
                        <div class="card-body p-2">
                            <ul class="list-unstyled mb-0 pl-2">
                                <li>
                                    <a href="/oauth2/login/jai">1. 授权码模式登录</a>
                                </li>
                                <li>
                                    <a href="/oauth2/login/implicit/jai">2. 隐式授权模式登录</a>
                                </li>
                                <li>
                                    <a href="/oauth2/login/password/jai">3. 密码授权模式登录</a>
                                </li>
                                <li>
                                    <a href="/oauth2/login/gitlab">Gitlab 登录</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-header p-2" id="oidcHeader">
                        <h2 class="mb-0">
                            <button class="btn btn-link btn-block text-left text-secondary collapsed" type="button" data-toggle="collapse" data-target="#oicContainer" aria-expanded="false" aria-controls="oicContainer">
                                <i class="fas fa-coffee mr-2"></i>oidc
                            </button>
                        </h2>
                    </div>
                    <div id="oicContainer" class="collapse" aria-labelledby="oidcHeader" data-parent="#accordionExample">
                        <div class="card-body p-2">
                            <ul class="list-unstyled mb-0 pl-2">
                                <li>
                                    <a href="/oidc/login/jai">OIDC 登录</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col col-8">
            <pre th:if="${userJson} ne null" class="rounded"><code class="json" th:text="${userJson}"></code></pre>
            <pre th:if="${userJson} eq null" class="rounded"><code class="html">尚未登录</code></pre>
        </div>
    </div>
</div>

</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.4.0/build/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script>
    function getUrlParam(key) {
        var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return r[2]; return null;
    }
    var error = getUrlParam("error");
    if(error) {
        $("#errorMsg").html(decodeURIComponent(error));
    } else {
        $("#errorMsg").hide();
    }
</script>
</html>
